package cn.south.campus.admin.sys.mapper;

import cn.south.campus.admin.sys.model.entity.SysMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 持久层
 *
 * @author chow
 * @since 2024-10-15
 **/
public interface SysMenuMapper extends BaseMapper<SysMenu> {


    /**
     * 查询用户的权限
     *
     * @param roleId 角色ID
     * @return 权限集合
     */
    List<String> selectPermissions(Long roleId);

    /**
     * 根据角色ID查询菜单
     *
     * @param roleId 角色ID
     * @return 菜单集合
     */
    @Select("select sm.* from sys_menu sm left join sys_role_menu srm on sm.id = srm.menu_id where srm.role_id = #{roleId} and sm.deleted = 0")
    List<SysMenu> selectMenusRoleId(Long roleId);
}
